package nr.nodehost;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import nr.nodehost.service.AsyncTaskService;

@ConfigurationProperties("node.listener")
@Component
public class Listener {
	private int port;
	private int timeout;
	private int maxFrameLength;


	@Autowired
	private Dispatcher dispatcher;
	@Autowired
	private AsyncTaskService taskService;
	public int getPort() {
		return port;
	}
	
	public void setPort(int port) {
		this.port=port;
	}
	
	public int getTimeout() {
		return timeout;
	}
	
	public void setTimeout(int timeout) {
		this.timeout=timeout;
	}
	
	public int getMaxFrameLength() {
		return maxFrameLength;
	}
	
	public void setMaxFrameLength(int maxFrameLength) {
		this.maxFrameLength=maxFrameLength;
	}
	public Dispatcher getDispatcher() {
		return dispatcher;
	}
	
	public void setDispatcher(Dispatcher dispatcher) {
		this.dispatcher=dispatcher;
	}
	
	public void start() {
		//	启动DALayer层连接，连接至数据中间件层
		taskService.Connect2DataAccess();
		taskService.runListener(this);
	}
}
